package client

import (
	"go_server/common"
	"sync"
)

// 处理函数的函数签名为-----传入的是包，返回的是字节流
type ClientMsgHandleMap struct {
	ChannelMap map[uint16]chan []byte
	Mtx        sync.RWMutex //用来互斥ChannelMap的
}

var ClientMsgHandleMapInstance *ClientMsgHandleMap = nil

func init() {
	//直接初始化
	ClientMsgHandleMapInstance = new(ClientMsgHandleMap)
	ClientMsgHandleMapInstance.ChannelMap = make(map[uint16]chan []byte)

}

// 用于发送已经序列化的数据
func clientSendMsg(id uint16, bodyLen uint32, body []byte, c *ClientSession) {
	//组装成包，放入
	Fullpkg := new(common.PackageStruct)
	Fullpkg.Body = body
	Fullpkg.Head = new(common.PackageHead)
	Fullpkg.Head.PkgId = id
	Fullpkg.Head.PkgBodyLen = bodyLen

	c.WritePkg <- Fullpkg

}
